package cn.edu.sdjzu.xg.eagle.entity;

import java.io.Serializable;
import java.time.LocalDateTime;

public class User implements Comparable<User>, Serializable {
    private static final long serialVersionUID = 1L; // 用于序列化版本兼容

    private Long id;
    private String username;
    private String password;
    private LocalDateTime loginTime;

    // 无参构造方法
    public User() {
    }

    // 全参构造方法
    public User(Long id, String username, String password, LocalDateTime loginTime) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.loginTime = loginTime;
    }

    // Getter 和 Setter 方法
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public LocalDateTime getLoginTime() {
        return loginTime;
    }

    public void setLoginTime(LocalDateTime loginTime) {
        this.loginTime = loginTime;
    }

    // 实现 Comparable 接口的 compareTo 方法
    @Override
    public int compareTo(User other) {
        if (other == null) {
            return 1; // 如果比较的对象为 null，认为当前对象更大
        }
        return this.id.compareTo(other.id); // 根据 id 进行比较
    }

    // 重写 toString 方法
    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", loginTime=" + loginTime +
                '}';
    }
}